package da.asclass.util
{
    import mx.collections.ArrayCollection;

    public class HashMap
    {
        private var arrColl:ArrayCollection;

        public function HashMap ()
        {
            this.arrColl = new ArrayCollection();
        }

        public function gets ( key:String ):Object
        {
            for each ( var obj:MapObject in this.arrColl )
            {
                if ( obj.key == key )
                {
                    return obj.value;
                }
            }
            return null;
        }

        public function puts ( key:String , value:Object ):void
        {
            if ( !this.arrColl.contains( value ))
            {
                this.arrColl.addItem( new MapObject( key , value ));
            }
        }

        public function remove ( key:String ):Boolean
        {
            var mo:MapObject = null;
            for ( var i:int = 0 ; i < this.arrColl.length ; ++i )
            {
                mo = MapObject( this.arrColl.getItemAt( i ));
                if ( mo.key == key )
                {
                    this.arrColl.removeItemAt( i );
                    return true;
                }
            }
            return false;
        }
    }
}